package org.qiandaosystem.qiandaosystemsource.mapper;

import org.apache.ibatis.annotations.*;
import org.qiandaosystem.qiandaosystemsource.entity.Student;

import java.util.List;

@Mapper
public interface StudentMapper {
    
    @Select("SELECT * FROM students WHERE user_id = #{userId}")
    Student findByUserId(Integer userId);

    @Select("SELECT * FROM students WHERE teacher_id = #{teacherId}")
    List<Student> findByTeacherId(Integer teacherId);
    
    @Insert("INSERT INTO students(user_id, real_name, teacher_id) VALUES(#{userId}, #{realName}, #{teacherId})")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    int insert(Student student);
    
    @Update("UPDATE students SET real_name = #{realName}, teacher_id = #{teacherId} WHERE user_id = #{userId}")
    int update(Student student);
} 